package com.cq.xjms.model;

import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 * 班级实体类
 * @author caiqiang
 * @version 1
 */
@Entity
@Table(name="Clazz")
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
@NamedQueries( {
	@NamedQuery(name = "Clazz.query", query ="select i from Clazz i where i.code=:code"),
	@NamedQuery(name = "Clazz.queryById", query ="select i from Clazz i left join fetch i.department d left join fetch i.department.institute n where i.id=:id"),
	@NamedQuery(name = "Clazz.queryAll", query ="select i from Clazz i left join fetch i.department  order by i.id"),
	@NamedQuery(name = "Clazz.queryLike", query ="select i from Clazz i left join fetch i.department  where i.department.name like :name"),
	@NamedQuery(name = "Clazz.list", query ="select i from Clazz i left join fetch i.department where i.department.id = :id order by i.id")
})
public class Clazz extends BaseEntity
{
	private static final long serialVersionUID = 1539350453366775796L;
	public static final String CLAZZ_QUERY = "Clazz.query";
	public static final String CLAZZ_QUERY_BYID = "Clazz.queryById";
	public static final String CLAZZ_LIST = "Clazz.list";
	public static final String CLAZZ_QUERYLIKE = "Clazz.queryLike";
	public static final String CLAZZ_LIST_ALL = "Clazz.queryAll";

	@Column(name = "NAME",length = 20)
	private String name;
	
	@Column(name = "CODE",length=10)
	private String code ;
	
	@ManyToOne(fetch = FetchType.LAZY)
	private Department department;
	
	@OneToMany(fetch = FetchType.LAZY,mappedBy="clazz")
	private List<Student> students;

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public Department getDepartment() {
		return department;
	}

	public void setDepartment(Department department) {
		this.department = department;
	}

	public List<Student> getStudents() {
		return students;
	}

	public void setStudents(List<Student> students) {
		this.students = students;
	}

	
	
	
	

}
